#!/usr/bin/env python3
import sys
import time

# ruleset
days_after_respawn = 6
days_after_spawn = 8
bound = max(days_after_respawn, days_after_spawn)

# helper function
def consume(countdown):
    value = countdown[0]
    countdown[0] = 0
    return value

# construct counter list and query input
countdown = [0] * (bound + 1)
for element in input().split(','): countdown[int(element)] += 1

# simulate each day
for day in range(128 if len(sys.argv) < 2 else int(sys.argv[1])):
    print(countdown)
    print(sum(countdown), 'fishies after', day, 'days')
    # extract respawns
    spawns = consume(countdown)
    # shift
    for i in range(bound):
        countdown[i] += countdown[i + 1]
        countdown[i + 1] = 0
    # apply previously extracted respawns
    countdown[days_after_respawn] += spawns
    countdown[days_after_spawn] += spawns
    #time.sleep(.01)
